package com.start.avue.configs;


import com.start.avue.mapper.*;
import com.start.common.std.StartBaseSingleton;
import com.start.common.std.StartSingletonFactory;

import java.util.HashMap;
import java.util.Map;

public class StartAvueMapperConfig extends StartBaseSingleton<StartAvueMapperConfig> {
    private static final Map<String, Class<? extends StartAvueMapper>> configMapper = new HashMap<>();
    private static Class<? extends StartAvueMapper> GLOBAL_DEF_MAPPER = AvueDefaultMapper.class;

    public static StartAvueMapperConfig getInstance() {
        return StartSingletonFactory.get(StartAvueMapperConfig.class);
    }

    @Override
    public void init() {
        configMapper.put(AvueDefaultMapper.MAPPER_TYPE, AvueDefaultMapper.class);//默认
        configMapper.put(AvueInputMapper.MAPPER_TYPE, AvueInputMapper.class);//输入框
        configMapper.put(AvueCascaderMapper.MAPPER_TYPE, AvueCascaderMapper.class);// 级联选择器
        configMapper.put(AvueTreeMapper.MAPPER_TYPE, AvueTreeMapper.class);//树型选择器
        configMapper.put(AvueCheckBoxMapper.MAPPER_TYPE, AvueCheckBoxMapper.class);//多选框
        configMapper.put(AvueDateMapper.MAPPER_TYPE_DATE, AvueDateMapper.class);//日期
        configMapper.put(AvueDateMapper.MAPPER_TYPE_TIME, AvueDateMapper.class);//时间
        configMapper.put(AvueDateMapper.MAPPER_TYPE_DATE_TIME, AvueDateMapper.class);//日期时间
        configMapper.put(AvueNumberMapper.MAPPER_TYPE, AvueNumberMapper.class);//数字
        configMapper.put(AvueRadioMapper.MAPPER_TYPE, AvueRadioMapper.class);//单选
        configMapper.put(AvueSelectMapper.MAPPER_TYPE, AvueSelectMapper.class);//下拉
        configMapper.put(AvueMapMapper.MAPPER_TYPE_2, AvueMapMapper.class);//地图
    }

    public Map<String, Class<? extends StartAvueMapper>> getConfigMapper() {
        return configMapper;
    }

    public static Class<? extends StartAvueMapper> getGlobalDefMapper() {
        return GLOBAL_DEF_MAPPER;
    }

    public void register(String colType, Class<? extends StartAvueMapper> clazz) {
        configMapper.put(colType, clazz);
    }


}
